import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Arrays;
import java.util.Random;

public class Text {
    public static void initArrayOrder(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }
    public static void initArrayNotOrder(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(10_0000);
        }
    }
    public static void textInsertSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TextSort.insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序的耗时：" + (endTime - startTime));
    }
    public static void testShellSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TextSort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时："+ (endTime-startTime));
    }

    public static void testSelectSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TextSort.selectSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时："+ (endTime-startTime));
    }

    public static void testHeapSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TextSort.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗时："+ (endTime-startTime));
    }
    public static void testBubbleSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TextSort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序耗时："+ (endTime-startTime));
    }
    public static void testQuickSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        TextSort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+ (endTime-startTime));
    }
    public static void main2(String[] args) {
        int[] array = new int[10_0000];
        initArrayOrder(array);
        //initArrayNotOrder(array);
        /*textInsertSort(array);
        testShellSort(array);
        testSelectSort(array);
        testHeapSort(array);
        testBubbleSort(array);*/
        testQuickSort(array);
    }
    public static void main(String[] args) {
        int[] array = {23,52,56,45,12,85,73};
//        TextSort.insertSort(array);
//        System.out.println(Arrays.toString(array));
//        TextSort.shellSort(array);
//        System.out.println(Arrays.toString(array));
//        TextSort.selectSort(array);
//        TextSort.heapSort(array);
//        System.out.println(Arrays.toString(array));
//        System.out.println(Arrays.toString(array));
//        TextSort.bubbleSort(array);
//        System.out.println(Arrays.toString(array));
//        TextSort.quickSort1(array);
//        System.out.println(Arrays.toString(array));
//        TextSort.mergeSort(array);
//        System.out.println(Arrays.toString(array));
        TextSort.countSort(array);
        System.out.println(Arrays.toString(array));
    }
}
